import myAxios from "../plugin/myAxios";
import {getCurrentState, setCurrentState} from "../state/user";


export const getCurrent:any =  async () => {
    const user = getCurrentState();
    if (user) {
        return user;
    } else {
        const res = await myAxios.get("/user/current")
        if (res.data) {
            setCurrentState(res.data)
            return res.data
        }
        return undefined;
    }
}